﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZX.EHR.Library;
using ZX.BLL.Extend;
using ZX.SYS.Library;
using ZX.Common;
using ZX.DAL.DBExtend;
using System.Data;
using System.Data.SqlClient;


namespace DCBH.Bussiness
{
    public class DCBHReport : BaseBussnies
    {
        private DbSql dbSql = new DbSql();
        //获取库存数据
        public DataTable ReturnBHInvBalance(string condition, string customCondition) 
        {
            string strSql = "select CompanyNo, CompanyName, ItemNo, ItemModel, ItemName, WarehouseName, Weight, Qty from V_BH_InvBalance where 1=1";
            strSql = strSql + (condition == "" ? "" : " and (" + condition + ")");
            strSql = strSql + (customCondition == "" ? "" : " and (" + customCondition + ")");
            strSql = strSql + " order by CompanyNo, ItemModel";
            return dbSql.ExecuteQuery(strSql);
        }

        //获取生产指示数据
        public DataTable GetBHWorkOrder(string condition, string customCondition) 
        {
            string strSql = "select ID, SystemGenNo, WorkOrderNo, Bu, CompanyName, PlanDate, ProductStartDate, ProductEndDate, BOMNo, ItemNo, ItemName, ItemModel, Weight, Price, Amount, Qty, Remark, ProcessingFlagText, AddUserName, AddTime from V_BH_WorkOrder where 1=1";
            strSql = strSql + (condition == "" ? "" : " and (" + condition + ")");
            strSql = strSql + (customCondition == "" ? "" : " and (" + customCondition + ")");
            
            return dbSql.ExecuteQuery(strSql);
        }

        public DataTable GetBHBomDetail(string bomNo)
        {
            string strSql = "select bd.BOMID, bom.ReferenceNo as BOMNo, bd.[LineNo], bd.ChildItemNo, bd.ItemModel, bd.ItemName, bd.Qty, bd.Scrap, bd.Remark from V_BH_BOMDetail bd left join BH_BOM bom on bd.BOMID = bom.ID where 1=1";
            strSql = strSql + (bomNo == "" ? "" : "  and (bom.ReferenceNo = '" + bomNo + "')");
            strSql = strSql + " order by bd.[LineNo]";

            return dbSql.ExecuteQuery(strSql);
        }
    }
}
